package com.wuhongyu;

import com.wuhongyu.linkList.LinkList;
import com.wuhongyu.stackAndqueue.ArrayQueue;
import com.wuhongyu.stackAndqueue.ArrayStack;
import com.wuhongyu.stackAndqueue.LoopQueue;
import com.wuhongyu.stackAndqueue.Queue;
import com.wuhongyu.tree.BSTree;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;

public class Main {

    //测试栈
    /*public static void main(String[] args){
        int[] array = {1,2,3,5,7,8,9};
        ArrayStack<Integer> stack = new ArrayStack<>();
        for (int i=0; i<array.length; i++)
            stack.push(array[i]);

        System.out.println(stack);
        stack.pop();
        System.out.println(stack);
    }*/

    // 测试使用q运行opCount个enqueueu和dequeue操作所需要的时间，单位：秒
 /*   private static double testQueue(Queue<Integer> q, int opCount){

        long startTime = System.nanoTime();

        Random random = new Random();
        for(int i = 0 ; i < opCount ; i ++)
            q.enqueue(random.nextInt(Integer.MAX_VALUE));
        for(int i = 0 ; i < opCount ; i ++)
            q.dequeue();

        long endTime = System.nanoTime();

        return (endTime - startTime) / 1000000000.0;
    }

    public static void main(String[] args) {

        int opCount = 100000;

        ArrayQueue<Integer> arrayQueue = new ArrayQueue<>();
        double time1 = testQueue(arrayQueue, opCount);
        System.out.println("ArrayQueue, time: " + time1 + " s");

        LoopQueue<Integer> loopQueue = new LoopQueue<>();
        double time2 = testQueue(loopQueue, opCount);
        System.out.println("LoopQueue, time: " + time2 + " s");

    }*/


 //测试自己写的链表
   /* public static void main(String[] args) {
        LinkList<Integer> linkList = new LinkList<>();
        for(int i=0; i<10; i++){
            linkList.addFirst(i);
        }
        System.out.println(linkList);
        System.out.println(linkList.removeLast());
        System.out.println(linkList);
    }*/

   //测试兰姆达表达式
   /*public static void main(String[] args) {
       List<User> list = new ArrayList<>();
       list.add(new User("赵欢",20));
       list.add(new User("赵欢",20));
       list.add(new User("赵欢",20));

       list.forEach((User u) -> System.out.println(u.getName()));
   }*/

    public static void main(String[] args) {
        BSTree<Integer> bsTree = new BSTree<>();
        Integer[] array = {5,3,2,4,1,6,8,25,7,9};
        for (Integer i: array) {
            bsTree.add(i);
        }
        bsTree.inOrder();
        bsTree.remove(6);
        bsTree.inOrder();
        //System.out.println(bsTree.contains(20));
        /*bsTree.removeMin();
        bsTree.removeMax();
        bsTree.inOrder();*/
       // System.out.println(bsTree.getMin());
       // System.out.println(bsTree.size());
        //System.out.println(bsTree.getMax());
    }

}